<template>
  <div>
    <BaseChart :options="chartData" />
  </div>
</template>

<script>
//Echarts组件封装引入
import BaseChart from "@/components/action/sales/Charts/BaseChart.vue";
//Axio引入
import axios from "axios";
export default {
  data() {
    return {
      chartData:{},//图表数据
    };
  },
  methods: {
    //分页
    handleSizeChange() {
      //console.log(`每页 ${val} 条`);
    },
    handleCurrentChange() {
      //console.log(`当前页: ${val}`);
    },
  },
  components: {
    BaseChart,
  },
  mounted() {
    //接口数据传输
    axios({
      url: "https://www.fastmock.site/mock/209040d286c0365d882a2dfa80a278fc/manager/store",
      method: "GET",
    })
      .then((res) => {
        // console.log("获取的数据：", res.data);
        this.chartData = {
          legend: {},
          tooltip: {},
          dataset: {
            dimensions: ["product", "销售额", "退货额"],
            source: res.data
          },
          xAxis: { type: "category" },
          yAxis: {},
          // Declare several bar series, each will be mapped
          // to a column of dataset.source by default.
          series: [{ type: "bar" }, { type: "bar" }],
        };

        setTimeout(() => {
          console.log("配置：", this.chartData);
        }, 100);
      })
      .catch((err) => {
        console.log("获取数据失败", err);
      });
  },
};
</script>

<style>
</style>